package com.liang.dao;
/*
 *@Author: ljy
 *@Date:2021/11/6 15:12
 *
 */

import com.liang.entity.Enclosure;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface EnclosureDao {
    /**
     * 附件上传
     *
     * @param fileName
     * @param size
     * @param fileUrl
     * @return
     */
    @Insert({
            "insert into enclosure(name,size,path,createtime) values(#{fileName},#{size},#{fileUrl},now())"
    })
    int upLoadEnclosure(@Param("fileName") String fileName, @Param("size") Float size, @Param("fileUrl") String fileUrl);

    /**
     * 根据主键id查询附件
     *
     * @param id
     * @return
     */
    @Select
            ({
                    "select",
                    "id, name, size,createtime,path",
                    "from enclosure",
                    "where id = #{id,jdbcType=INTEGER}"
            })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "size", property = "size", jdbcType = JdbcType.DOUBLE),
            @Result(column = "createtime", property = "createtime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "path", property = "path", jdbcType = JdbcType.VARCHAR)
    })
    Enclosure selectEnclosureByPrimaryKey(Integer id);
}
